<template>
  <div class="regular_container">
    <el-row :gutter="10">
      <div>
        <div class="left_item">

          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane v-for="(item, index) in this.tabsData" :key="index" :index="item.id" :label="item.name" :name="item.id+''">
              <div class="cotent">

                <div class="imgbox clearfix">
                  <div>
                    <img class="bgImg" src="/assets/image/depart_img_1@2x.png" alt="">
                  </div>

                  <div>
                    <img class="bgImg" src="/assets/image/depart_img_2@2x.png" alt="">
                  </div>

                </div>
                <ul class="newItem regularItem clearfix">
                  <li v-for="item in list" :key="item.id" @click="details(item.id)">
                    <p><span class="content text-1"><i class="circle"></i>{{item.title}}</span><span class="time">{{item.createTime.substring(0,10)}}</span></p>
                  </li>
                </ul>
              </div>
            </el-tab-pane>
          </el-tabs>

        </div>

      </div>
    </el-row>
  </div>
</template>
<script>

import path from '@/network'
export default {
  name: 'App',
  data () {
    return {
      title: '民生动态',
      activeName: 'first',
      tabsData: [],
      total: 0,
      pagesize: 20,
      currentPage: 1,
      detailsId: '',
      list: [],
    };
  },

  mounted () {
    this.getSecondType(this.$route.query.firstId);
  },
  methods: {
    handleClick (tab) {
      this.detailsId = tab.paneName;
      this.getRulesList(this.detailsId)

    },
    //获取list
    getSecondType (id) {
      path.getSecondType(
        id
      ).then(res => {
        if (res.success === 0) {
          this.tabsData = res.rows;
          if (res.rows) {
            this.getRulesList(res.rows[0].id)
            this.activeName = res.rows[0].id + ''
          }

        }

      })
    },



    //获取list
    getRulesList (id) {
      path.getRulesList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.list = res.rows;
        }

      })
    },
    details: function (id) {
      this.$router.push({ name: 'newsDetails', query: { secondId: id, firstId: this.$route.query.firstId, type: 2 } })

    },

  }
}
</script>